package com.kaiyidiannao.data;

/**
 * Created by mark on 2014/4/25.
 */
public class Validate {
    //手机验证
    public static final String phoneValidate = "^(13[0-9]|15[012356789]|18[0236789]|14[57])[0-9]{8}";

    //邮箱验证
    public static final String emailValidate = "^[0-9a-zA-Z]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$";

    //密码验证
    public static final String passwordValidate = "^[0-9a-zA-Z]{6,20}";

    //日期验证
    public static final String dateValidate = "/((^((1[8-9]\\d{2})|([2-9]\\d{3}))([-\\/\\._])(10|12|0?[13578])([-\\/\\._])(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\\d{2})|([2-9]\\d{3}))([-\\/\\._])(11|0?[469])([-\\/\\._])(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\\d{2})|([2-9]\\d{3}))([-\\/\\._])(0?2)([-\\/\\._])(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([3579][26]00)([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([1][89][0][48])([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([2-9][0-9][0][48])([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([1][89][2468][048])([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([2-9][0-9][2468][048])([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([1][89][13579][26])([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([2-9][0-9][13579][26])([-\\/\\._])(0?2)([-\\/\\._])(29)$))/ig";

    //姓名验证
    //  public static final String truenameValidate = "[\\u4E00-\\u9FA5]{2,5}(?:·[\\u4E00-\\u9FA5]{2,5})*";

    //qq验证
    public static final String qqValidate = "^[1-9]\\d{3,10}";

    //昵称验证
    public static final String usernameValidate = "^[\\u4e00-\\u9fa5]{4,16}|[a-zA-Z0-9]{2,8}$";


    //地址验证
    public static final String addressValidate = "[\\u4E00-\\u9FA5A_a-zA-Z0-9]{6,30}";

    //店名验证
    public static final String sellerValidate = "[\\u4E00-\\u9FA5A_a-zA-Z0-9]{1,30}";

    public static boolean truenameValidate(String str) {
        String[] strs = str.split(" ");
        if (str.length() >= 2 && str.length() <= 5) {
            if (str.startsWith(" ")) {
                return false;
            } else if (str.endsWith(" ")) {
                return false;
            } else if (strs.length > 1) {
                return false;
            } else {
                return true;
            }
        } else {
            return false;
        }
    }

    public static boolean search(String str) {
        String[] strs = str.split(" ");
        if (str.startsWith(" ")) {
            return false;
        } else if (str.endsWith(" ")) {
            return false;
        } else if (strs.length > 1) {
            return false;
        } else {
            return true;
        }
    }

}
